﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true"
    CodeBehind="MyTracks.aspx.cs" Inherits="VO.Web.MyTracks" %>

<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <h2>
        My Tracks
    </h2>
    <asp:UpdatePanel ID="pnlTrackMain" runat="server">
        <ContentTemplate>
            <asp:UpdatePanel ID="pnlTrackList" runat="server">
                <ContentTemplate>
                    <asp:LinkButton ID="btnAddTrack" runat="server" OnClick="btnAddTrack_Click" CssClass="linkButton">
                        <asp:Image ID="Image1" runat="server" ImageUrl="images/add-icon-24.png" BorderStyle="None"
                            CssClass="addTrackIcon" />Add new track</asp:LinkButton><br />
                    <asp:GridView ID="gvTrackList" runat="server" AutoGenerateColumns="False" DataSourceID="ObjectDataSource1"
                        CssClass="gridTrackList" DataKeyNames="Id" OnRowCommand="gvTrackList_RowCommand">
                        <Columns>
                            <asp:BoundField DataField="Id" HeaderText="Id" SortExpression="Id" Visible="False" />
                            <asp:BoundField DataField="UserId" HeaderText="UserId" SortExpression="UserId" Visible="False" />
                            <asp:BoundField DataField="TrackName" HeaderText="TrackName" SortExpression="TrackName" />
                            <asp:BoundField DataField="TrackCategoryId" HeaderText="TrackCategoryId" Visible="False"
                                SortExpression="TrackCategoryId" />
                            <asp:TemplateField HeaderText="TrackCategory" SortExpression="TrackCategoryId" ItemStyle-HorizontalAlign="Center">
                                <ItemTemplate>
                                    <%# GetTrackCategory((int)Eval("TrackCategoryId"))%>
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:BoundField DataField="Version" HeaderText="Version" SortExpression="Version"
                                Visible="False" />
                            <asp:CheckBoxField DataField="Locked" HeaderText="LockedHidden" Visible="False" ItemStyle-HorizontalAlign="Center"
                                SortExpression="Locked" />
                            <asp:TemplateField HeaderText="Locked" SortExpression="Locked" ItemStyle-HorizontalAlign="Center">
                                <ItemTemplate>
                                    <asp:Image ID="imgLocked" runat="server" ImageUrl='<%# (bool)Eval("Locked") ? "~/images/lock-icon-16.png" : "~/images/unlock-icon-16.png" %>'
                                        ToolTip='<%# (bool)Eval("Locked") ? "Track locked (already done by users)" : "Track unlocked (can be edited)" %>' />
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:BoundField DataField="Level" HeaderText="Level" SortExpression="Level" ItemStyle-HorizontalAlign="Center" />
                            <asp:BoundField DataField="LastEditDate" HeaderText="LastEditDate" SortExpression="LastEditDate"
                                Visible="False" />
                            <asp:BoundField DataField="CreatedDate" DataFormatString="{0: dd/MM/yyyy}" HeaderText="CreatedDate"
                                SortExpression="CreatedDate" ItemStyle-HorizontalAlign="Center" />
                            <asp:TemplateField HeaderText="Edit" ItemStyle-HorizontalAlign="Center">
                                <ItemTemplate>
                                    <asp:ImageButton ID="btnEditDetails" runat="server" Visible='<%# (bool)Eval("Locked") ? false : true %>'
                                        CommandName="EditDetails" CommandArgument='<%# Eval("Id") %>' ImageUrl="~/images/edit-icon.gif" />
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="Delete" ItemStyle-HorizontalAlign="Center">
                                <ItemTemplate>
                                    <asp:ImageButton ID="btnDelete" runat="server" Visible='<%# (bool)Eval("Locked") ? false : true %>'
                                        CommandName="DeleteTrack" OnClientClick="return confirm('Are you sure you want to delete this track?');"
                                        CommandArgument='<%# Eval("Id") %>' ImageUrl="~/images/icon-delete-16.png" />
                                </ItemTemplate>
                            </asp:TemplateField>
                        </Columns>
                    </asp:GridView>
                    <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" SelectMethod="GetUserTracks"
                        TypeName="VO.Business.Controllers.TracksController">
                        <SelectParameters>
                            <asp:SessionParameter DefaultValue="0" Name="userId" SessionField="UserId" Type="Int32" />
                        </SelectParameters>
                    </asp:ObjectDataSource>
                </ContentTemplate>
            </asp:UpdatePanel>
            <br />
            <asp:UpdatePanel ID="pnlTrackDetails" runat="server" class="hidePanel">
                <ContentTemplate>
                    <asp:Label ID="lblTrackName" runat="server" Text="Track Name"></asp:Label>
                    <asp:TextBox ID="txtTracksName" runat="server"></asp:TextBox>
                    <asp:LinkButton ID="btnSaveTrack" runat="server" CssClass="linkButton" OnClick="btnSaveTrack_Click">
                        <asp:Image ID="Image2" runat="server" ImageUrl="images/icon-save-24.png" BorderStyle="None"
                            CssClass="addTrackIcon" />
                        Save Track</asp:LinkButton>
                    <asp:LinkButton ID="btnCancel" runat="server" CssClass="linkButton" OnClick="btnCancel_Click">
                        <asp:Image ID="Image3" runat="server" ImageUrl="images/icon-cancel-24.png" BorderStyle="None"
                            CssClass="addTrackIcon" />
                        Cancel</asp:LinkButton>
                        <br />
                        Track category
                        <asp:DropDownList ID="cboTrackCategory" runat="server" />
                    <div id="mapEditControl">
                        <div id="mapEditControlToolbox" class="mapEditControlToolbox">
                            Search location 
                            <asp:TextBox ID="txtSearchAddress" runat="server"></asp:TextBox>
                            <asp:ImageButton ID="btnSearchAddress" ImageUrl="~/images/search-location-icon-24.png"
                                runat="server" CssClass="toolboxImageButton" OnClick="btnSearchAddress_Click" />
                            Zoom track
                            <asp:ImageButton ID="btnFitTrackInView" ImageUrl="~/images/fit-icon-24.png" runat="server"
                                CssClass="toolboxImageButton" OnClick="btnFitTrackInView_Click" />
                        </div>
                        <div id="panelMap" class="panelMap">
                            <asp:Panel ID="trackMap" runat="server">
                                <artem:GoogleMap ID="gMap1" runat="server" Width="640px" Height="500px" Latitude="47.156944"
                                    Longitude="27.590278" Zoom="14" EnableScrollWheelZoom="true" DefaultMapView="Satellite"
                                    ZoomPanType="Small3D">
                                </artem:GoogleMap>
                            </asp:Panel>
                        </div>
                    </div>
                </ContentTemplate>
            </asp:UpdatePanel>
        </ContentTemplate>
    </asp:UpdatePanel>
    <br />
</asp:Content>
